package io;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class WriteStringDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("data.txt");
        String str = "夜空中最亮的星，请指引我前行。";
        byte[] len = str.getBytes(StandardCharsets.UTF_8);
        fos.write(len);

        str = "那仰望的人，心底的孤独和叹息。";
        len = str.getBytes(StandardCharsets.UTF_8);
        fos.write(len);
        System.out.println("写出完毕");
        fos.close();
    }
}
